package br.com.gecandango.service.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import br.com.gecandango.beans.Prato;
import br.com.gecandango.service.PratoService;

public class PratoServiceImpl extends HibernateDaoSupport implements
	PratoService {
	
	public Prato save(Prato bean) {
		Long id;
		if(bean.getId()==null){
			id =  (Long)getHibernateTemplate().save(bean);
			bean.setId(id);
		} else {
			getHibernateTemplate().saveOrUpdate(bean);
		}
		return bean;
	}
	public List<Prato> list() {
		return getHibernateTemplate().find("from Prato");
	}
	public Prato find(Long id) {
		List<Prato> e = (List<Prato>)getHibernateTemplate().find("from Prato where id=?", id);
		return e.get(0);
	}
	
	public void delete(Prato bean) {
		getHibernateTemplate().delete(bean);
	}	
}
